#ifndef FRAMELESS_H
#define FRAMELESS_H

#include <QMargins>
#include <QPoint>
#include <QRect>

class QWidget;
class QEvent;
class QMouseEvent;
class QFocusEvent;
class Frameless
{
public:
    Frameless(QWidget *self);

protected:
    enum Direction {
        UP = 0,
        DOWN,
        LEFT,
        RIGHT,
        LEFTTOP,
        LEFTBOTTOM,
        RIGHTBOTTOM,
        RIGHTTOP,
        NONE
    };

    virtual QMargins layoutMargins() = 0;
    virtual bool canWindowMove() = 0;
    virtual bool canResize();

    void focusInEvent(QFocusEvent *e);
    bool mousePressEvent(QMouseEvent *e);
    void mouseMoveEvent(QMouseEvent *e) ;
    void mouseReleaseEvent(QMouseEvent *);
    void event(QEvent *e);

    void calcRegion(const QPoint &cursorGlobalPoint);
//    void resetResource();

private:
    QWidget *m_self;
    QPoint m_point;
    QPoint dragPosition;
    Direction dir;
    bool leftButtonPress;
};

#endif // FRAMELESS_H
